import request from '@/utils/request'

const loginApi = {
  // 密码登录
  loginByPassword: (data) => {
    return request({
      url: '/system/auth/newLogin',
      header: {
        isToken: false,
        'tenant-id': 1
      },
      method: 'POST',
      data
    })
  },
  // 手机号登录
  loginByPhone: (data) => {
    return request({
      url: '/system/auth/new_sms-login',
      header: {
        isToken: false,
        'tenant-id': 1
      },
      method: 'POST',
      data
    })
  },
  refreshToken: (token) => {
    return request({
      url: `/system/auth/refresh-token?refreshToken=${token}`,
      method: 'POST'
    })
  },
  // 发送验证码
  sendMsgCode: (data) => {
    return request({
      url: '/system/auth/send-sms-code',
      method: 'POST',
      data
    })
  },
  // 获取用户详细信息
  getUserInfo: (params) => {
    return request({
      url: '/system/user/get',
      method: 'GET',
      params
    })
  },
  // 退出登录
  logout: () => {
    return request({
      url: '/system/auth/logout',
      method: 'POST'
    })
  },
  // 是否已有供应链
  getRegisterInfo: () => {
    return request({
      url: '/system/supply-chain/api/getReqisterInfo',
      method: 'GET'
    })
  },
  // 获取租户列表
  getTenantList: (userId) => {
    return request({
      url: `/system/user/getTenant-SCM?id=${userId}`,
      method: 'GET'
    })
  },
  // 切换租户的登录
  loginTenant: (data) => {
    return request({
      url: '/system/auth/login',
      header: {
        isToken: false
      },
      method: 'POST',
      data
    })
  },
  // 注销账号
  logOffUser: (id) => {
  	return request({
  		url: `/system/user/signOutUser?id=${id}`,
  		method: 'POST',
  	})
  },
  // 获取部门列表
  getDeptList: (userId) => {
    return request({
      url: `/system/user/getCompany?id=${userId}`,
      method: 'GET'
    })
  },
}
export default loginApi